package wwiii;

public class MapGenerator_Galaxy extends MapGenerator {
	public MapGenerator_Galaxy(int areas, int sizex, int sizey, int areaSize) {
		super(areas, sizex, sizey, areaSize);
	}

	@Override
	public void createAreas(AreaMap map) {
		int count = 0;

		while (map.getAreaCount() < areas) {
			if (count++ > 1000) break;

			String name = "area"+ map.getAreaCount();
			double a = Math.random()*Math.PI*2;
			double b = Math.random();
			int x = (int) (Math.cos(a)*sizex*b+sizex)/2;
			int y = (int) (Math.sin(a)*sizey*b+sizey)/2;
//			int x = (int) (Math.random()*(sizex - MIN_AREA_AREA_DISTANCE)+ MIN_AREA_AREA_DISTANCE/2);
//			int y = (int) (Math.random()*(sizey - MIN_AREA_AREA_DISTANCE)+ MIN_AREA_AREA_DISTANCE/2);
			Player owner = new Player("id", "mail", "name", 0);
			int force = 0;

			if (testArea(map, x, y)) {
				map.addArea(new Area(name, x, y, owner, force));
			}
		}

		System.out.println(map.getAreaCount() +" "+ areas);
	}
}
